package com.service.component.common.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.util.ObjectUtils;

import javax.validation.constraints.PastOrPresent;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;

@Slf4j
@Getter
@Setter
@ToString
@ApiModel(value = "公共实体类")
/**
 * @author ：Calvin
 * @date ：Created in 2021/7/16 14:35
 * @description：公共实体类，所有实体都需要有的字段
 * @modified By：
 * @version: 1.0.0$
 */
public class CommonEntity implements Serializable {

    /**
     * 主键
     */
    @TableId(type = IdType.ASSIGN_UUID)
    @ApiModelProperty(value = "主键")
    private String id;

    /**
     * 创建人
     */
    @ApiModelProperty(value = "创建人编号")
    @TableField(value = "CREATO_NO", fill = FieldFill.INSERT)
    private String creatoNo;

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    @TableField(value = "CREATE_TIME", fill = FieldFill.INSERT)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @PastOrPresent(message = "创建时间不能大于当前时间")
    private Timestamp createTime;

    /**
     *
     */
    @ApiModelProperty(value = "修改人编号")
    @TableField(value = "MODIFIER_NO", fill = FieldFill.INSERT_UPDATE)
    private String modifierNo;
    /**
     * 修改时间
     */
    @ApiModelProperty(value = "修改时间")
    @TableField(value = "UPDATE_TIME", fill = FieldFill.INSERT_UPDATE)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @PastOrPresent(message = "创建时间不能大于当前时间")
    private Timestamp updateTime;
}
